<?php require_once('Connections/db_conn.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<?php
mysql_select_db($database_db_conn, $db_conn);
$query_type = "SELECT * FROM type ORDER BY TYPE ASC";
$type_all= mysql_query($query_type, $db_conn) or die(mysql_error());
$row_type = mysql_fetch_assoc($type_all);
$totalRows_type = mysql_num_rows($type_all);

$layout = explode('&&&', file_get_contents('layout.html'));
echo $layout[0];

session_start();
if (!(isset($_SESSION['username'])))
	header("location:login.php");

$id=$_GET['id'];
?>

<html>
<head>
 <script language="JavaScript" src="calendar3.js"></script>
</head>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
<body>

<!-- Begin Main Column -->

<div id="mainContent">

  <h2>Edit Participant Type </h2>

      <p></p>
    <form id="form1" method="post" action="">
          <table width="300" border="0">

             <tr>  <label>
                <td> Old Participant Type:</td>
                <td>


			            <select name="type_ed" id="type_ed">

			              <?php
			do {
			?>

				<option value="<?php echo $row_type['TYPE']?>"><?php echo $row_type['TYPE']?></option>


			              <?php
			} while ($row_type = mysql_fetch_assoc($type_all));
			  $rows = mysql_num_rows($type_all);
			  if($rows > 0) {
			      mysql_data_seek($type_all, 0);
				  $row_type = mysql_fetch_assoc($type_all);
			  }
			?>
			            </select>
            </label>
</td>
            </tr>
                       <tr>
				              <td>New Participant Type:</td>
				              <td><label>
				                <input type="text" name="type_new" id="type_new"/>
				              </label></td>
				            </tr>
				          </table>
				          <p>
				            <label>
				            <input type="submit" name="type_search" id="type_search" value="Submit" class="button" />
				            </label>
				          </p>
         </table>

        </form>

<!-- Begin Side Column -->
<!-- Begin Footer -->

<?php
			if($_POST) {
			ob_start();
			$host="localhost"; // Host name
			$username="root"; // Mysql username
			$password=""; // Mysql password
			$db_name="rtl"; // Database name

			// Connect to server and select databse.
			mysql_connect("$host", "$username", "$password")or die("cannot connect");
			mysql_select_db("$db_name")or die("cannot select DB");


			$type_ed=$_POST['type_ed'];

			// To protect MySQL injection (more detail about MySQL injection)
			$type_ed = stripslashes($type_ed);
			$type_ed = mysql_real_escape_string($type_ed);

			$type_new=$_POST['type_new'];

			// To protect MySQL injection (more detail about MySQL injection)
			$type_new = stripslashes($type_new);
			$type_new = mysql_real_escape_string($type_new);
	
			if($type_new !="")
			{
				mysql_query("UPDATE type SET TYPE = '$type_new' WHERE TYPE = '$type_ed'");
			}
			}

	?>
    </div>



<?php
echo $layout[1];
?>
</body>
</html>
